<template>
  <template v-for="(menu, index) in menus" :key="index">
    <template v-if="menu.children">
      <lay-sub-menu :id="menu.id" :teleportProps="teleportProps">
        <template #icon>
          <j-icon :name="menu.icon"></j-icon>
        </template>
        <template #title>{{ menu.title }}</template>
        <Item :menus="menu.children"></Item>
        <template v-slot:expandIcon={isExpand}>
          <lay-icon v-if="isExpand" type="layui-icon-down"></lay-icon>
          <lay-icon v-else type="layui-icon-right"></lay-icon>
        </template>
      </lay-sub-menu>
    </template>
    <template v-else>
      <lay-menu-item :id="menu.id">
        <template #icon>
          <j-icon :name="menu.icon"></j-icon>
        </template>
        <template #title>{{ menu.title }}</template>
      </lay-menu-item>
    </template>
  </template>
</template>

<script setup lang="ts">
import Item from "./item.vue"

defineProps({
  teleportProps: {
    type: Object,
  },
  menus: {
    type: Object
  }
})
</script>
<style lang="less" scoped>
:deep(.layui-nav-tree) {
  .layui-nav-item > a {
    height: 40px;
    line-height: 40px;
    position: relative;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    padding: 0 !important;
  }
}


</style>
